<?php
namespace Managers;
use \Site\Housing as HousingEntity;

class Housing extends BaseManager{
    public function getAll(){
        return $this->getEntityManager()
                ->createQueryBuilder()
                ->select('n')
                ->from('Site\Housing', 'n')
                ->orderBy('n.id', '')
                ->where('n.published = 2')
                ->getQuery()
                ->getResult();
    }

    public function getOne($id){
        return $this->getEntityManager()
                ->createQueryBuilder()
                ->select('n')
                ->from('Site\Housing', 'n')
                ->where('n.id = :id')
                ->getQuery()
                ->setParameters(array('id'=>$id))
                ->getSingleResult();
    }

    public function getNewNotPub(){
        return $this->getEntityManager()
                ->createQueryBuilder()
                ->select('n')
                ->from('Site\Housing', 'n')
                ->where('n.published = 1')
                ->orderBy('n.id', 'desc')
                ->getQuery()
                ->getResult();
    }

    public function getNew(){
        return $this->getEntityManager()
                ->createQueryBuilder()
                ->select('n')
                ->from('Site\Housing', 'n')
                ->where('n.published = 2')
                ->orderBy('n.id', 'desc')
                ->setMaxResults(10)
                ->getQuery()
                ->getResult();
                
    }

}